/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-09-07
 * Time: 22:13
 */
public class Test {
    public ListNode removeDuplicateNodes(ListNode head) {
        ListNode cur = head;
        while (cur != null) {
            ListNode temp = cur;
            while (temp.next != null) {
                if (temp.next.val == cur.val) {
                    temp.next = temp.next.next;
                } else {
                    temp = temp.next;
                }
            }
            cur = cur.next;
        }
        return head;
    }
    public static int[] reversePrint1(ListNode head) {
        ListNode cur = head;
        int count = 0;
        while(cur != null){
            cur = cur.next;
            count++;
        }
        int[] arry = new int[count];
        int right = arry.length - 1;
        cur = head;
        while(cur != null){
            arry[right] = cur.val;
            cur = cur.next;
            right--;
        }
        return arry;
    }


}
